home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16764 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  43 lines

  1. Path: holly.ACNS.ColoState.EDU!not-for-mail
  2. From: corbyh@holly.ACNS.ColoState.EDU (Corby S. Hudnall)
  3. Newsgroups: comp.lang.c++
  4. Subject: Copy constructor
  5. Date: 11 Apr 1996 15:43:14 -0600
  6. Organization: Colorado State University, Fort Collins, CO  80523
  7. Message-ID: <4kjudi$2qj0@holly.ACNS.ColoState.EDU>
  8. NNTP-Posting-Host: holly.acns.colostate.edu
  9. X-Newsreader: TIN [version 1.2 PL2]
  10.  
  11. Hi all, I'm having some trouble figuring out how to do a copy 
  12. constructor.  Here's what I thought was suppose to work:
  13.  
  14. header file----
  15. class ABC
  16. {
  17.     private:
  18.         int AnInt;
  19.  
  20.     public:
  21.         ABC():AnInt(5) {}  // Default Constructor
  22.         ~ABC() {}          // Default Destructor
  23.         ABC(const ABC&);   // Copy constructor
  24. }
  25.  
  26. ABC::ABC(const ABC& NewABC)
  27. {
  28.    this->AnInt = NewABC->AnInt;
  29. }
  30.  
  31. Unfortunatly, I can't get this to work right.  I get weird messages from 
  32. the compiler complaining about not being able to use a class definition 
  33. as an argument.  This was using xlC under IBM Aix.  Any suggestions are 
  34. greatly appreciated.  Thanks.
  35.  
  36.  
  37.           T E A R   A L O N G  T H E   D O T T E D  L I N E
  38. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  39. Corby S. Hudnall                 Junior, Spring 1996
  40. Colorado State University        http://WWW.CS.ColoState.EDU/~hudnall
  41. Department of Computer Science   hudnall@CS.ColoState.EDU
  42.  
  43.